
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Fast SpringBoot</title>
    <link href="https://s2.ufubank.com/framecore/font/iconfont.css" rel="stylesheet">
    <link href="https://s2.ufubank.com/framecore/sweet-alert/css/sweet-alert.css" rel="stylesheet">
    <link href="https://s2.ufubank.com/ums/static/style/bootstrap.css?ver=3.21" rel="stylesheet">
    <link href="https://s2.ufubank.com/ums/static/style/font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="https://s2.ufubank.com/ums/static/style/login.css" rel="stylesheet" type="text/css">


    <style>
        * { margin:0; padding:0; }
        body { background:#111; height:100%; }
        img { border:none; }




        .actions #submit{
            background: #0089fd none repeat scroll 0 0;
            width: 240px;
        }
        .actions #submit:disabled{
            background: #6699cc none repeat scroll 0 0;
        }
    </style>
</head>
<body>

<div class="loginbox">
    <div class="title">
        <div class="logo"><i class="iconfont" style="font-size:36px;">&#xe602;</i>Fast SpringBoot</div>
        <div class="info">—综合管理系统</div>
    </div>
    <div class="form">
        <form  class="form-signin" method="post">
            <!-- 1 -->
            <!-- 2 -->
            <form name="form" method="post">
                <div class="inputs">
                    <div><span>用户名：</span><input type="text" name="username" placeholder="用户名" id="username"></div>
                    <div><span>密码：</span><input type="password" name="password" placeholder="密码" id="password"></div>
                </div>
                <div class="actions">
                    <input id="submit" value="登录" type="button">
                </div>
                <div class="msg"></div>
                <div style="clear:both;"></div>
                <div class="guest"></div>
            </form>
    </div>
</div>
<div class="common_footer">Use SpringBoot</div>
<script src="https://s2.ufubank.com/framecore/jquery-2.1.1.min.js"></script>
<script src="https://s2.ufubank.com/framecore/jquery.form.js"></script>
<!--SweetAlert-->
<script src="https://s2.ufubank.com/framecore/sweet-alert/js/sweet-alert.js"></script>
<script src="https://s2.ufubank.com/framecore/layer/layer.js"></script>


<script>

    $(function(){



        //Enter登录事件绑定
        $(document).keydown(function(e){
            if(e.keyCode == 13) {
                var isUser=$("#username").val();
                var isPass=$("#password").val();
                if(isUser!="" && isPass!=""){
                    $("#submit").click();
                    return false;
                }
            }
        });


        $("#submit").on('click',function(){
            //验证
            if($("#username").val() == '') {
                $('.msg').show();
                $('.msg').html("请输入用户名！");
                $("#username").focus();
                return false;
            }
            if($("#password").val() == ''){
                $('.msg').show();
                $('.msg').html("请输入密码!");
                $("#password").focus();
                return false;
            }

            $("#submit").prop('disabled',true);
            $("#submit").attr("value","登录中...");

            var qsData = {username:$("#username").val(), password:$("#password").val()};
            $.ajax({
                type: "POST",
                async: false,
                url: "/login/form",
                data: qsData,
                timeout: 5000,
                dataType : "json",
                beforeSend: function () {

                },
                success: function(data){
                    if (data.resultStatus == "0000") {
                        $("#submit").attr("value","登录成功");
                        location.href = '/home';
                    } else {
                        $('.msg').show();
                        $('.msg').html('用户名或密码错误！');
                        $("#password").val("");
                    }
                },
                complete:function(){
                    //启用登陆按钮
                    $("#submit").prop('disabled',false);
                    $("#submit").attr("value","立即登录");
                },
                error: function(XMLHttpRequest, textStatus, errorThrown){
                    $('.msg').show();
                    $('.msg').html("登录出现错误，系统可能出现异常情况！");
                    console.log("登录出现错误，系统可能出现异常情况！");
                    //启用登陆按钮
                    $("#submit").prop('disabled',false);
                    $("#submit").attr("value","立即登录");
                }
            });
        });


    });
</script>
</body>
</html>